change logging statement from print statement to log function