If you need to reuse this logic it should be a separate function.