Added check for filetype