problem 12: solved
problem 12: first optimization after reading paper
problem 12: second optimization after reading paper