Fixed bug in SQL insert