adding in generation and output of x matrix