modified sceletion cachematrix as per assignment requirements