code is optimized for better performance
Logging text fixed