call function appropriately