refactored patch to avoid issues when using legacy loading