added modifications by andrea bontempelli