(probably not) final working version, figure out tests, better modularity, and stuff