Further refined algorithm (also fixed rare monitor error)