Maybe this is better as a function due to multiple `&&`s.