made this utility more generic