making logic a bit more generic