Enum validation added

Enum validation added and refactoring to reduce source code