Fixed syntax error and added some error handling