refactor sign in/up handlers