fix syntax and refactor