Fix for force close on Android 4.3 devices

I noticed this after updating my Nexus 4 to Android 4.3.

I took the liberty to refactor your code a little bit :)