optimize not naive seems to work