remove extra var
add check for empty versions when building trees