improve error handling
change function name