implement ROCK Algorithm