Code refactoring and safer behavior