consolidated some redundant code.