Why am I skipping to a different page despite no condition exists?