added lifetime for object and improved scanner