euhm, can we do the if logfile outside the function?