Fixed bug with crashing