improvements and more DRY