Refactor Array.prototype functions