fixed function for pre-generating stage matrices