remove double function call, be smarter