finished all functions with some issues