bug fixes from previous commit