put functions in logical order