generally working now. kind of hacky and sloppy