static handler and better error handling