Completed program, get correct Output