addapted to new functions