re-factor; no more repeated code