DRY and removed unused code