fix syntax and logic