Added validity checks and grammar.