fixed erroneous code