cleaned up the functions