added functionality that fixed bug in opening files