added grid display and refactored