synched java implementation with MATLAB code, translated a comment to english