fixed syntax errors and other errors and tested with test.py