functon logic added