improving scan_ functions