Refactor update_lru function