added validation and refactored profile controller