similar code finded on forums - Need some tests to be used