added error handling in case some one puts in incorrect SQL