using proper function to detect if user is logged in