fixed some broken scripts due to a bad previous rollback
complete functioning script