changed the if condition for checking if the object is empty or not.