moved the functions out of main kernel