stop passing -1 to appendLog and append message inside for loop/if statement'