Fixing bad code