rewrite in python
minor fix