fixed bug in RHS and cleaned up output a bit