logic for id='selected' and main.html fix