extended example to lock when app enters background