First of all, use helper functions or explicit for loops.
E.g. you're looping over m.tm four times. This can be done in a single loop. It might need more lines of code, but it will get much more readable.
First of all, use helper functions or explicit for loops.
E.g. you're looping over m.tm four times. This can be done in a single loop. It might need more lines of code, but it will get much more readable.