Refactor duplications
Fix syntax errors