Finished implementation for executeFactory procedure.