restructuring
rewriting checks in Perl