rewritten functions to match up