improve memory consumption