man, this puzzle took me a long time to figure out, my brain just could not optimise it any better so this is gonna be it :D