fix comments, reorder function