moved if clause into main