adding more error handling