solved
streamlined solution by an order of magnitude, bitches\!