solved #8. there are still some optimizations to be had.