added code to switch between card up and card down