improved some code