Can now correct ~ with home dir, refactoring