reordered a few functions