Improving code

Add next handler method
Add flag dir for the filename