More effective algorithm considering API constraints