Added logic for file exstensions