$filename can also be resource