Move lines into fn
Use winston; improve log messages