changing turn into function