Replaced error checks with direct returns in scanning functions