continued port from djed scripts