new version if stiching algorithm