card mode logic added