changed so that length is only checked if null passes