Improved logging

code refactoring, avoid logging empty strings