I agree with previous posts. Too many while loops complicate your algorithm.