refactor logins controller