Refactored with path support