Refactored to use logging module