All these functions are very similar, as suggested by @JASON0916 we could simplify them using a decorator.