Improved some code