a version with new functions but not tested yet.