Refactoring, debug text added