cleaned up function for readability