Implement offset and change rank algorithm