In shell scripts inside [[ .. ]] blocks, ">" is a string comparison operator. The return value check using it appears to work mostly by accident, because the only values are "0" and "1". Change to -gt operator.