converting prototype to be more OO