Refactor and implement validations.