Fixing bug in code?