Refactoring not working completely