added filetype checking to the script