refactored grid