very sloppy, but i think its done