refactored with only before method