refactoring of validation to improve source code readability.
fix small bug introduced in refactoring
Documentation of the function