adds validation and error checking