Refactored based on comments. Added test to ensure warning comes up.