refactored ugly file extension getter