Refactor the Api#next_build method.