more efficient electons algorithm