onTheSameSide function work