consolidated some more code