improved code layout

no changes to original code or function so far