few more checks in code for prevent problems and errors