moved functions into some files