adding some checks to ensure file exists