Started to clean up, made dictionary creation a separate function, check for existence of file