Bug fixe refactoring