Updated method to fix crash