quick fix for a bug; need robust fix