Edited and added comments
Replaced print messages with proper logging statements.