added eoin's code