fix remove function bug reported in #1