updated matchPrefix to use mask