refactor variable bug