just re-wote in python
re-wrote in python