add select related and fix needless queries