port to python
added replace