fixing scope query