Fixed logging code