Modify function that processes images