better dynamic object code + refactoring into dynamicObject.js