debugged terrible code