Re-implementation of Array.map done