fixes #21, its the same as Pyxides/lsm.py