Changes to fix the crashing issue