Refactored validate into two parts