simplified all the things

totally rewrote the function., back to erik.