added comments and fixed popup window so it closes when cancel is
pressed