few improvments of code