refactored runOnce