main logic update