algo for api works with edge cases of ing