(refactor) make blocks of functions
(refactor) move blocks to proper places