fix bug: wrong syntax & improper logic