fix and add some functions