added check to make sure filename is valid