removed trailing whitespace and inlined variables to functions