refactored code, added more tests, extended documentation
return None instead of raising an error