Fixed the masked data array by splitting the array using split() then writing the code.