Refactored log in template