added origin logic