Fixing scope function