Re-wrote file type checking