When costly migration helps to improve cooperation