fixing bug with Array.map etc