working, about to change the order of things for major speedup