Made some changes to the new code

Changes were made but a few bugs still exist