rewrite of updatePixData to use 4D array