add syntax validation and rename local vars