Proper fix for IllegalArgumentException