Improve error handling.

For error handling create an extra variable that explains the returned boolean for validation to improve code readability.