unit tested and corrected