complete login functionality
refactor code