refactor render.js so it works with scope.js

changed some code from render.js so now it works with scope.js