Created new module and functions to simplify update function in main code
Added more functions to module