bug fixes - tests passing