Fixed database queries, used insert() instead of query()