Refactored to load workflow from database