started to create generic functions and remove multiple similar ones.