Refactor code for guidelines