edited for DRY