apply language bug-fix and move datetime checking to the first line