added checking for cancan and change layout for popup