consolidated some functions