Fixing bug when range length is 0