Minor edits to function