Moved functions into individual files