added a decorator to reduce redundant code