Updated some function that contained errors