Implemented decision function but need to debug a bit