Refactored dangerous code