throwing some errors for invalid ranges