added a function that calculates msf, it needs to be split in other functions