adds else cases to algorithm