made and fixed  functions to create/ generate grid