added dynamic filename handling