refined stale removal algorithm and debugged