moved validating to functions