-- updated and refctored login functionality