moved org handling to function