added conditionals to logging