refactor to a prototype approach; documentation