Move mass stuff into functions