added automatic file recognition. no need for flag anumore :)