move the log statement to inside if block