refactor optional functions