extracted a few functions