changed api to use reflection