Added more functions to simplify scripts
Improved flexibility and simplified code with new shared functions