added error handling to create message