Fixed error with lexos.py code moved into function