Updated version of checkLogin