better testing and error handling