Removed mask loading from the algorithm