@Override
	public BakingActionResult checkActionIsApplicableInState(State state, String[] params) {
		BakingActionResult superResult = super.checkActionIsApplicableInState(state, params);
		
		if (!superResult.getIsSuccess()) {
			return superResult;
		}
		
		String agentName = params[0];
		ObjectInstance agent =  state.getObject(agentName);
		
		if (AgentFactory.isRobot(agent)) {
			return BakingActionResult.failure(agentName + " cannot perform this action");
		}
		
		String pouringContainerName = params[1];
		ObjectInstance pouringContainer = state.getObject(params[1]);
		
		String receivingContainerName = params[2];
		ObjectInstance receivingContainer = state.getObject(params[2]);

		String pouringContainerSpaceName = ContainerFactory.getSpaceName(pouringContainer);
		String receivingContainerSpaceName = ContainerFactory.getSpaceName(receivingContainer);
		ObjectInstance receivingContainerSpace = state.getObject(receivingContainerSpaceName);
		
		if (ContainerFactory.isEmptyContainer(pouringContainer)) {
			return BakingActionResult.failure(pouringContainerName + " is empty");
		}
		
		if (!ContainerFactory.isReceivingContainer(receivingContainer)) {
			return BakingActionResult.failure(receivingContainerName + " cannot be poured into");
		}
		
		if (pouringContainerSpaceName == null || receivingContainerSpaceName == null)
		{
			throw new RuntimeException("One of the pouring containers is not in any space");
		}
		
		if (SpaceFactory.isBaking(receivingContainerSpace)) {
			return BakingActionResult.failure(receivingContainerName + " is in the " +  receivingContainerSpaceName+ " which is a baking space!");
		}
		ObjectInstance pouringContainerSpaceObject = state.getObject(pouringContainerSpaceName);
		
		String agentOfSpace = SpaceFactory.getAgent(pouringContainerSpaceObject).iterator().next();
		if (!agentOfSpace.equalsIgnoreCase(agentName))
		{		
			return BakingActionResult.failure(agentName + " cannot work in " + pouringContainerSpaceName);
		}
		if (!SpaceFactory.isWorking(pouringContainerSpaceObject)) {
			return BakingActionResult.failure("Pouring cannot be performed in the " + pouringContainerSpaceObject);
		}
		return BakingActionResult.success();
	}