optimized handler for android lifecycle