almost done but some core dumps when larger then 3x3