throwing error in query when property is not defined