add some validation, cleanup