polished main() and rip() functions