fixed a bunch of bugs but majorly need a refactor