updated main and added error() global script function