cleaned up scanning method