Fixed small logical error