Using While in place of conditional If statement