Refactored scope replacement
Finished scope replacements