Added check for non-zero length key