add debug logging functionality
added debug functions throughout code