trying to improve memory handling