user login optimise and bug fix