a bit of code cleanup and simplification