LogMessage func added
Refactored