Refactor code: split into functions and reformat