rewrite, refactor, optimize
fixing child() and other bugs