refactored rhea and made it commandline program as well