Login functionality revised