refactored some code and removed some Function constructors as a form of eval