New function for sqare grid generation