more range-based for-loop
reducing too many levels of indentation
changing a state variable into a function in case the state changes