modified functions for cachematrix.R file