refactor and add check script