This optimization should be done in a little bit different way - but that's fine for now