Working X Matrix Code