Version 1.3 2022.06.21
Added additional checks and improvements of the algorithm