Tweaked the function