Utility randomInRange function implemented