index functions as both table and function