login tidy up and fixed errors