Remove duplicated if-statement in AppKernel