Added logic test and made a few minor changes