extracted algorithm that is very similar to current implementation of multicompiler farm