rewrote as framework agnostic. I may regret this