insert sign checking
revert previous algorithm