Fixed bug that crashed program when pausing activity