Factored mask generation code into seperate component.