working and terribly janky version ... will eventually clean up