debuged check() function