updated to do mass functions