This calculation should probably also be a function somewhere so that we don't have to repeat it everywhere.