Finished the logic code. (FATAL BUG in code somewhere)