mostly refactoring and code maintainance
pile.js: length was returning the array itself