main loop
main loop
merging