better error and validation handling