Implementing comming algorithm