Added defensive programming for empty sentences