implements login function