bug fixes - tests all passing