Fixed some bugs in the programming