refactoring; tested with 5.3-beta