done main functionality. now it's mostly just refactoring