Refactor to prototype