streamlining the ugly code. it's still not exactly beautiful, though. (#30)