finish all functions of first version