Changed the function

Made some mistakes and made them better