Refine code for login view.