Adding in some error handling