Added better file handing