Adding logging araound the application and handling nan properly