code improvements

more checks