added login function for less code