Added mask check when extracting data