need conditional check for user object  to avoid  Null pointer exception