Added chiniu's bugfix