fixing error in bad code