refined funcitons for better testability