document detect and release