simpified code a lot