added logic to controller