code refactoring. Make better file extention retrieving