Call to a member function getElement() on null