adds validation, bug fixes