refactor to a prototype approach