improved error handling and typos