Updated scopes a bit and removed unused var