made minor stylistic adjustments from mateiz