Added type check for stat write out