2d code actually working this time