Refactoring bugfix