tested refactoring and adding helper functions from Simplex.java