tested, still minor bugs