Created validation functions.
Improved code maintainability and readability.