Update initializeMatrix method