Adding isset checks and fixed the $output in buildCheckFields