consolidated some code