main logic done!