Modification to login function