rework error handling
improve error throwing