simplified some code