function maaaaaybe too long, lots of variable bindings tho. could maybe be split up