Tested and corrected errors