improved rama.py