better way to detect number of cores