More edits to make sql working