add new method and remove redundant code