imporved cache limit algorithm