fixed some errors made in removing code duplication