make sign function idempotent