trying to make error handling better