added some new functions and templates