script bug fixes