cleaned up code, removed loggingFunction option