fixed a nasty bug