moved verfiying of filename to the top