constructing feature matrix