Small refactory of HasNext method