Fix bug in filename generation