Version taken from A. Fois homepage