rewrite the login mechanism