refactor sql parser