fixed bugs in new functions