Refactored code and added EOL