added better logging functionality