modified trebor.py with new glm-function that works better and faster than older ones