only call strlen once