broke down the logic in getRemainingWords. Easier to read now