refactor queries && fix some stupid mistakes!