finish all functions, need testing