removed redundant code by creating a base controller