completed STATE + ERROR monad