Use range() properly