add comments, condense custom sqlquery into one file