optimizing code, replacing extend with prototypical inheritance instead