added check if space filled and maximum total moves