Refined the SQL insertion