#558 refactored