remove trailing whitespace and correct indentation
make loop factors static, because they will not change at all