Fix typo and reduce nesting