Updated the broken function and fixed it