Cleaned up validation code to be a little easier on the eyes