added all checks required for part 3
output result