adding some error handling