refactoring to a more prototypal approach