Bug fixes and remove repitition from login