Separated logic into functions and functionsIn (with prototype)