Fixed bug and checked a user is logged in.