closing #24 in a more generic way