Fixed the bug mentioned by timorl