fixed up bad code