removed unnecessary debug statement
added short-circuit evaluation