added safe extension method + tests