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

[ALOY-1052] add in the missing ;