ipy scripts; refactoring