Refactor sign in