Replaced print calls by logging function