Added flock checking for better checking