changed classBased.js. it works, but has protection against cyclic depedancy