fixing scope bugs