refactored some functionality into OOJS