Renaming some things and separate a function