Made my changes to the function