implemented code to prevent overshot node