removing borked attempt at making this into a class, rewrite from scratch