changed ends to make more MATLAB friendly