less code dup and more log functions