code cleanup
add some functions