Changed the code to fix mass detector issue