added methods to calculate optimal Matrix values