handle trailing spaces on keywords