mysql error handling added