Trying to fix broken code