Added ECMAScript 5 functionality to the current code and removed some unnecessary lines