fixed two queue algorithm
added documentation