Added Custom FileName settings

refactored the code (a bit)