Added grid logic