Finished range detection. Had to add border to make it work.