Fixed some bugs and check the condition if a piece can't move