rewrote in js. made module loading recursive to avoid missing modules