updated script for output and filename