Can you add some whitespace/new-lines to this function, or refactore it into smaller functional chunks?