Made it into a function