fix ref-before-assignment