refactoring to use prototype