fixed bug with opening files