Move check into separate function