still refactoring functions around S4 structure and writing tests