[ALOY-1052] move check to a function for reusability