improvement on some functions

improvement on some functions