Fixed the mask function to AND truth values together