improved block script with variable directory