refactoring bugfixig