Improved random search optimization template