added guard and some other stuff