improving matrix library