Removed @TargetApi so it should work with the new min SDK (no doubt it wasn't working for anything less than KitKat)
Refactored code