logging is working now, code needs refactoring