splitted wcheck.sh into functions