Some logic added.