more python code added; still doesn't work correctly