Adding logging code