Added rows() and columns() and used it throughout the code