refactoring in template to login