updated from master with new functions