replaced Mat by Input/Output arrays