debug localization? + refactoring