refactor controller
add login to db and refactor controller