Some improvement of code