clean up of skeleton algorithm