refactored run method