Implemented decision making logic and fixed some things