Sign in and up code refactor