rearranged checked for better output