finally fixed a nasty bug