refactoring, TODO:move sql to files