refactoring: State Int -> State (Maybe Int)