fix bug causing too many DB calls