simplifying the code not to use the prototype chain