move guard into pattern match