modified functions moving to remove redundant code