Add last line
Add index line
Fill last line
Extract matrix creation into a class