done with little bit of linear algebra