handle all errors correctly at the top