fixed possible null exception in findValidCard function