To implement flock