Put process handling in seperate function