Used checked function instead of using if condition for displaying checked attribute