Add logs and fix ref