big refactor and cleaned up entire logic... still could be cleaner