Small refactoring and syntax error correction