fix ref after moving code