main logic done