runs a lot faster, and fixed a bug