improved significantly arxiv.py