Fixing bug w/ nested ifs