changed file extension checking to use os.path.splitext instead of regex