fix logic and syntax