Better functionalize code, reduce repeated code