fixed typo in variable declaration of msg in error handling