final untested version of realtime.py