has a weird bug but I think I got the basic framework working