Neaten & improve functions structure