modified for older ruby