Remove newline
Refactored validate method into two methods