Reorganizing functions for readability