Interactive Grid Code refactored