added the k finding function and cleaned up the singeOutcome function