modify input and delete the temporary arrays