Improved some parts of code