changed selectedId to use id instead