merge all code to reduce memory use