fix a bug in code, thanks to Liusic